package aad.storyboard.model.menu;

import aad.storyboard.model.Chapter;
import aad.storyboard.model.Scene;
import aad.storyboard.model.Story;

public class MenuProvider {
	
	private Story story;
	
	private static MenuProvider instance = new MenuProvider();
	
	public static MenuProvider getInstance(Story s){
		instance.setStory(s);
		return instance;
	}

	public void buildInitialMenu(MenuBuilder builder){
		builder.initialise();
		builder.createLookSettings();
		builder.createTitle("Main Menu");
		builder.createText("Welcome to the Jabberwocky land. Select what you want to do next!");
		builder.createStartButton();
		builder.createChapterButton();
		builder.createSettingsButton();
		builder.createAboutButton();
		builder.createExitButton();
	}
	
	public void buildPauseMenu(MenuBuilder builder){
		builder.initialise();
		builder.createTitle("Pause");
		builder.createLookSettings();
		builder.createResumeButton();
		builder.createRestartButton();
		builder.createChapterButton();
		builder.createSettingsButton();
		builder.createMainMenuButton();
		builder.createExitButton();
	}
	
	public void buildFinalMenu(MenuBuilder builder){
		builder.initialise();
		builder.createLookSettings();
		builder.createRestartButton();
		builder.createMainMenuButton();
		builder.createExitButton();
		
	}

	public void buildChapterSelectionMenu(MenuBuilder builder){
		builder.initialise();
		builder.createLookSettings();
		builder.createTitle("Chapters");
		for(Chapter c : Story.getInstance().getChapters()){
			System.out.println("CHapter" +c.getId()+c.getStartTime());
			builder.createChapterSelectionButton(c.getId());
		}
		builder.createMainMenuButton();
		builder.createExitButton();
		
	}

	
	private void setStory(Story s) {
		this.story = s;
		
	}

	public void buildSceneMenu(MenuBuilder builder,int i) {
		builder.initialise();
		builder.createLookSettings();
		builder.createTitle("Main Menu");
		Chapter chapter = null;
		Scene scene = null;
		for(Chapter c : story.getChapters()){
			if(c.getId() == i){
				for(Scene s : c.getScenes()){
					builder.createSceneSelectionButton(s.getId());
				}
			}
		}
		builder.createMainMenuButton();
		builder.createExitButton();
		
	}
	
	public void buildSettingsMenu(MenuBuilder builder){
		builder.initialise();
		builder.createLookSettings();
		builder.createTitle("Settings");
		builder.createVolumeController();
		builder.createWikiButton();
		builder.createScriptButton();
		builder.createMainMenuButton();
		builder.createExitButton();
		
	}

}
